/**
 * 
 */
package client;

import bean.LineItem;
import bean.Order;
import bean.ShoppingCart;

import javax.naming.InitialContext;

/**
 * PatternBox: "Client" implementation.
 * <ul>
 *   <li>This represents the client of the Session Facade, which needs access to the business service. </li>
 * </ul>
 * 
 * @author Dirk Ehms, <a href="http://www.patternbox.com">www.patternbox.com</a>
 * @author Blito
 */
public class Client
{
	/** This will be our sessionBean */
	private static bean.ShoppingCartBean session = null;
	
	/** 
	 * This construtor for the Client
	 */
	public Client() {
		session = new bean.ShoppingCartBean();
	}
	
	/** 
	 * This method returns an in that is fetched from a BussinesComponent
	 */
	public void useServiceA() {
		Object param1 = new String("myString");
		//Object result = session.useServiceA(param1);
	}

   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      ShoppingCart cart = (ShoppingCart) ctx.lookup("ShoppingCartBean/remote");

      System.out.println("Buying 2 memory sticks");
      cart.buy("Memory stick", 2, 500.00);
      System.out.println("Buying a laptop");
      cart.buy("Laptop", 1, 2000.00);

      System.out.println("Print cart:");
      Order order = cart.getOrder();
      System.out.println("Total: $" + order.getTotal());
      for (LineItem item : order.getLineItems())
      {
         System.out.println(item.getQuantity() + "     " + item.getProduct() + "     " + item.getSubtotal());
      }

      System.out.println("Checkout");
      cart.checkout();

   }
}